package com.leizhou.configuration;

import com.leizhou.pojo.User;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author LT
 * @version 1.0.0
 * @ClassName UserProperties.java
 * @Description TODO 定义属性类
 * 将需要注入的属性定义成一个属性类,创建bean对象。这样做属性类就可以重复使用。
 * - @ConfigurationProperties: 配置属性
 * - @Component: 创建普通bean对象(泛指组件，当组件不好归类的时候，可以使用这个注解)
 * @createTime 2020年04月16日 00:35:00
 */
@ConfigurationProperties(prefix = "my")
@Component
public class UserProperties {
    private String host;
    private int port;
    private User user;
    private String[] address;
    private List<User> users;


    public UserProperties() {
    }

    public UserProperties(String host, int port, User user, String[] address, List<User> users) {
        this.host = host;
        this.port = port;
        this.user = user;
        this.address = address;
        this.users = users;
    }

    /**
     * 获取
     *
     * @return host
     */
    public String getHost() {
        return host;
    }

    /**
     * 设置
     *
     * @param host
     */
    public void setHost(String host) {
        this.host = host;
    }

    /**
     * 获取
     *
     * @return port
     */
    public int getPort() {
        return port;
    }

    /**
     * 设置
     *
     * @param port
     */
    public void setPort(int port) {
        this.port = port;
    }

    /**
     * 获取
     *
     * @return user
     */
    public User getUser() {
        return user;
    }

    /**
     * 设置
     *
     * @param user
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * 获取
     *
     * @return address
     */
    public String[] getAddress() {
        return address;
    }

    /**
     * 设置
     *
     * @param address
     */
    public void setAddress(String[] address) {
        this.address = address;
    }

    /**
     * 获取
     *
     * @return users
     */
    public List<User> getUsers() {
        return users;
    }

    /**
     * 设置
     *
     * @param users
     */
    public void setUsers(List<User> users) {
        this.users = users;
    }

    @Override
    public String toString() {
        return "UserProperties{host = " + host + ", port = " + port + ", user = " + user + ", address = " + address + ", users = " + users + "}";
    }
}
